<!DOCTYPE html>
<html lang="en"class="page-fill" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>Fly Template v3.0，基于 layui 的极简社区页面模版</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="keywords" content="fly,layui,前端社区">
  <meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
  <link rel="stylesheet" href="../../res/layui/css/layui.css">
  <link rel="stylesheet" href="../../res/css/global.css">
</head>
<body>
<div th:replace="pages/common/header :: head"></div>
<div class="layui-hide-xs">
  <div class="fly-panel fly-column">
    <div class="layui-container">
      <ul class="layui-clear">
        <li class="layui-hide-xs"><a href="/">首页</a></li> 
        <li class="layui-this"><a href="">提问</a></li> 
        <li><a href="">分享<span class="layui-badge-dot"></span></a></li> 
        <li><a href="">讨论</a></li> 
        <li><a href="">建议</a></li> 
        <li><a href="">公告</a></li> 
        <li><a href="">动态</a></li> 
        <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li> 
        
        <!-- 用户登入后显示 -->
        <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="../user/index.html">我发表的贴</a></li> 
        <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="../user/index.html#collection">我收藏的贴</a></li> 
      </ul> 
      
      <div class="fly-column-right layui-hide-xs"> 
        <span class="fly-search"><i class="layui-icon"></i></span> 
        <a th:href="'/article/add'" class="layui-btn">发表新帖</a>
      </div> 
      <div class="layui-hide-sm layui-show-xs-block" style="margin-top: -10px; padding-bottom: 10px; text-align: center;"> 
        <a th:href="'/article/add'" class="layui-btn">发表新帖</a>
      </div> 
    </div>
  </div>
</div>

<div class="layui-container">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md8 content detail">
      <div class="fly-panel detail-box">
        <h1 th:text="${article.title}"></h1>
        <div class="fly-detail-info">
          <!-- <span class="layui-badge">审核中</span> -->
          <span class="layui-badge layui-bg-green fly-detail-column">动态</span>
          
          <span class="layui-badge" style="background-color: #999;">未结</span>
          <!-- <span class="layui-badge" style="background-color: #5FB878;">已结</span> -->
          
          <span class="layui-badge layui-bg-black">置顶</span>
          <span class="layui-badge layui-bg-red">精帖</span>
          
          <div class="fly-admin-box" data-id="123">
            <span class="layui-btn layui-btn-xs jie-admin" type="del">删除</span>
            
            <span class="layui-btn layui-btn-xs jie-admin" type="set" field="stick" rank="1">置顶</span> 
            <!-- <span class="layui-btn layui-btn-xs jie-admin" type="set" field="stick" rank="0" style="background-color:#ccc;">取消置顶</span> -->
            
            <span class="layui-btn layui-btn-xs jie-admin" type="set" field="status" rank="1">加精</span> 
            <!-- <span class="layui-btn layui-btn-xs jie-admin" type="set" field="status" rank="0" style="background-color:#ccc;">取消加精</span> -->
          </div>
          <span class="fly-list-nums"> 
            <a href="#comment"><i class="iconfont" title="回答">&#xe60c;</i> 66</a>
            <i class="iconfont" title="人气">&#xe60b;</i> 99999
          </span>
        </div>
        <div class="detail-about">
        <a class="fly-avatar" th:href="'/user/home/'+${article.artUserId}" link>
          <img src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" alt="贤心">
        </a>
        <div class="fly-detail-user">
          <a th:href="'/user/home/'+${article.artUserId}" class="fly-link">
            <cite th:text="${article.artUserId}"></cite>
            <i class="iconfont icon-renzheng" title="认证信息：{{ rows.user.approve }}"></i>
            <i class="layui-badge fly-badge-vip">VIP3</i>
          </a>
          <span th:text="${#dates.format(article.createTime, 'yyyy-MM-dd HH:mm:ss')}"></span>
        </div>
        <div class="detail-hits" id="LAY_jieAdmin" data-id="123">
          <span style="padding-right: 10px; color: #FF7200">悬赏：60飞吻</span>
          <span class="layui-btn layui-btn-xs jie-admin" type="edit"><a href="add.html">编辑此贴</a></span>
        </div>
      </div>

        <div class="detail-body photos">
         <div th:utext="${article.content}"></div>
      </div>

      <div class="fly-panel detail-box" id="flyReply">
        <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
          <legend>回帖</legend>
        </fieldset>

        <ul class="jieda" id="jieda">
          <div th:if="${comments} ne null">
            <div th:each="comment:${comments}">
          <li data-id="111" class="jieda-daan">
            <a name="item-1111111111"></a>
            <div class="detail-about detail-about-reply">
              <a class="fly-avatar" href="">
                <img src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg" alt=" ">
              </a>
              <div class="fly-detail-user">
                <a href="" class="fly-link">
                  <cite th:text="${comment.comUserId}"></cite>
                  <i class="iconfont icon-renzheng" title="认证信息：XXX"></i>
                  <i class="layui-badge fly-badge-vip">VIP3</i>              
                </a>
                
                <span>(楼主)</span>
                <!--
                <span style="color:#5FB878">(管理员)</span>
                <span style="color:#FF9E3F">（社区之光）</span>
                <span style="color:#999">（该号已被封）</span>
                -->
              </div>

              <div class="detail-hits">
                <span th:text="${#dates.format(comment.comTime, 'yyyy-MM-dd HH:mm:ss')}"></span>
              </div>

              <i class="iconfont icon-caina" title="最佳答案"></i>
            </div>
            <div class="detail-body jieda-body photos">
              <div th:utext="${comment.comContent}"></div>
            </div>
            <div class="jieda-reply">
              <span  class="jieda-zan" type="zan">
                <i id="thumbType" class="iconfont icon-zan"></i>
                <em id="thumbNum" th:text="${article.likeNum}"></em>
              </span>
              <span type="reply">
                <i class="iconfont icon-svgmoban53"></i>
                回复
              </span>
              <div class="jieda-admin">
                <span type="edit">编辑</span>
                <span type="del">删除</span>
                <!-- <span class="jieda-accept" type="accept">采纳</span> -->
              </div>
            </div>
          </li>
            </div>
          </div>
        </ul>

        <!-- 分页-->
        <div id="pagesplit"></div>
        <!-- 回复文本框-->
        <div class="layui-form layui-form-pane">
          <form class="layui-form" lay-filter="submitBtn"
                enctype="multipart/form-data">
            <input type="hidden" name="comUserId" th:value="${session.user.id}">
            <input type="hidden" name="comArtId" th:value="${article.articleId}">
            <div class="layui-form-item layui-form-text">
<!--              <a name="comment"></a>-->
              <div class="layui-input-block">
                <textarea name="comContent" id="edit" cols="30" rows="10"></textarea>
              </div>
            </div>
            <div class="layui-form-item">
              <button class="layui-btn" lay-event="getContent">提交回复</button>
<!--              <button class="layui-btn" lay-filter="submitBtn" lay-submit></button>-->
            </div>
          </form>
        </div>
      </div>
    </div>
    </div>
    <div class="layui-col-md4">
      <dl class="fly-panel fly-list-one">
        <dt class="fly-panel-title">本周热议</dt>
        <dd>
          <a href="">基于 layui 的极简社区页面模版</a>
          <span><i class="iconfont icon-pinglun1"></i> 16</span>
        </dd>
        <dd>
          <a href="">基于 layui 的极简社区页面模版</a>
          <span><i class="iconfont icon-pinglun1"></i> 16</span>
        </dd>
        <dd>
          <a href="">基于 layui 的极简社区页面模版</a>
          <span><i class="iconfont icon-pinglun1"></i> 16</span>
        </dd>
        <dd>
          <a href="">基于 layui 的极简社区页面模版</a>
          <span><i class="iconfont icon-pinglun1"></i> 16</span>
        </dd>
        <dd>
          <a href="">基于 layui 的极简社区页面模版</a>
          <span><i class="iconfont icon-pinglun1"></i> 16</span>
        </dd>
        <dd>
          <a href="">基于 layui 的极简社区页面模版</a>
          <span><i class="iconfont icon-pinglun1"></i> 16</span>
        </dd>
        <dd>
          <a href="">基于 layui 的极简社区页面模版</a>
          <span><i class="iconfont icon-pinglun1"></i> 16</span>
        </dd>
        <dd>
          <a href="">基于 layui 的极简社区页面模版</a>
          <span><i class="iconfont icon-pinglun1"></i> 16</span>
        </dd>
        <dd>
          <a href="">基于 layui 的极简社区页面模版</a>
          <span><i class="iconfont icon-pinglun1"></i> 16</span>
        </dd>
        <dd>
          <a href="">基于 layui 的极简社区页面模版</a>
          <span><i class="iconfont icon-pinglun1"></i> 16</span>
        </dd>

        <!-- 无数据时 -->
        <!--
        <div class="fly-none">没有相关数据</div>
        -->
      </dl>

      <div class="fly-panel">
        <div class="fly-panel-title">
          这里可作为广告区域
        </div>
        <div class="fly-panel-main">
          <a href="http://layim.layui.com/?from=fly" target="_blank" class="fly-zanzhu" time-limit="2017.09.25-2099.01.01" style="background-color: #5FB878;">LayIM 3.0 - layui 旗舰之作</a>
        </div>
      </div>

      <div class="fly-panel" style="padding: 20px 0; text-align: center;">
        <img src="../../res/images/weixin.jpg" style="max-width: 100%;" alt="layui">
        <p style="position: relative; color: #666;">微信扫码关注 layui 公众号</p>
      </div>

    </div>
</div>
</div>
<div th:replace="pages/common/footer :: footer"></div>
<script src="../../res/layui/layui.js"></script>
<script>
  layui.extend({
    tinymce: '/res/libs/tinymce/tinymce'
  }).use(['tinymce','layer', 'form','jquery', 'util'], function(){
    var layer = layui.layer
            ,form = layui.form
            ,$ =layui.jquery;
    var tinymce = layui.tinymce;

    var util = layui.util;

    var edit = tinymce.render({
      elem: "#edit"
      , height: 600
    });
    // tinymce.init({
    //   selector: '#edit',
    //   plugins: ['paste', 'link', 'code','image'],
    //   toolbar: 'image',
    //   images_upload_handler: function (blobInfo, succFun, failFun) {
    //     var xhr, formData;
    //     xhr = new XMLHttpRequest();
    //     xhr.withCredentials = false;
    //     xhr.open('POST', '/article/fileUpload');
    //     formData = new FormData();
    //     formData.append('file',blobInfo.blob() );//此处与源文档不一样
    //     xhr.onload = function() {
    //       var json;
    //       if (xhr.status != 200) {
    //         failFun('HTTP Error: ' + xhr.status);
    //         return;
    //       }
    //       json = JSON.parse(xhr.responseText);
    //       if (!json || typeof json.location != 'string') {
    //         failFun('Invalid JSON: ' + xhr.responseText);
    //         return;
    //       }
    //       succFun(json.location);
    //     };
    //     xhr.send(formData);
    //   }
    // });
    util.event('lay-event', {
      getContent: function () {
        var content = tinymce.get('#edit').getContent()
        layer.alert(content);
      }
    });


    $("#thumbType").click(function () {
      console.log("点击是有效的")
      $.post("/article/likeArticle/"+[[${article.articleId}]]+'/'+[[${session.user.id}]],function(d){
        if (d.code == 200) {
          console.log("回调也成功乐")
          $("#thumbType").parent().attr("class",'jieda-zan zanok');
          $("#thumbNum").text(eval([[${article.likeNum}]]+1));
        } else {
          layer.msg(d.message,{"icon":2});
        }
      })
    });


    //如果成功跳转到个人的主页
    form.on('submit(submitBtn)', function(data){
      console.log("data: "+JSON.stringify(data))
      var comment = data.field;

      $.post("/comment/save",comment,function(d){
        if (d.code == 200) {
          layer.msg("评论提交成功！");

          //刷新父页面
          parent.location.reload();
        } else {
          layer.msg(d.message,{"icon":2});
        }
      });

      return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });


  });

</script>

</body>
</html>